import { Component, OnInit } from '@angular/core';
import { ApkDataService } from '../service/apk-data.service';
import { NgxSpinnerService } from "ngx-spinner";
import { Router } from '@angular/router';
@Component({
  selector: 'app-apk-pentest',
  templateUrl: './apk-pentest.component.html',
  styleUrls: ['./apk-pentest.component.css']
})
export class ApkPentestComponent implements OnInit {

  fileToUpload: File = null;
  fileName="Choose APK file";
  isUploaded=false;
  constructor(
    private apkDataService:ApkDataService,
    private router:Router,
    private spinner: NgxSpinnerService
  ) { }
  

  ngOnInit(): void {
  }
 

  handleFileInput(files: FileList) {
    this.fileToUpload = files.item(0);
    this.fileName=this.fileToUpload.name
    this.isUploaded=true
}




uploadFileToActivity() {
  this.spinner.show();
  this.apkDataService.postFile(this.fileToUpload).subscribe(data => {
      this.apkDataService.scannedData=data
      this.spinner.hide();
      this.router.navigate(['report'])
    }, error => {
      console.log(error);
      this.spinner.hide();
      this.router.navigate(['**'])
    });
}
}
